<template>
	<view class='content'>
		<view style="height: 10px;"></view>
		<view class="bg_header">
			<view class="qiu">
				<view class="text money">{{ user.total_integral}}</view>
				<view class="text">总环保金</view>
			</view>
			<view class="desc">
				可提现金额: {{ user.money}}元
			</view>
		</view>
		
		<view class="tixiantype">
			<view class="card" @click="gotocashlist()">
				<u-image width="50px" height="50px" src="../../static/icon_00.png"></u-image>
				<view class="card_title">
					提现明细
				</view>
			</view>
			<view class="card" @click='cash()'>
				<u-image width="50px" height="50px" src="../../static/icon_04.png"></u-image>
				<view class="card_title">
					提现
				</view>
			</view>
			
			<view class="cashlist" @click='gotocashRule'>
				提现规则
			</view>
		</view>
		
		<view class="list_title">
			环保金明细
		</view>
		
		<view class="list">
			<view class="list_item" v-for="(item,index) in list" :key="index">
				<view class="time">
					创建时间:{{ time(item.ctime)}}
				</view>
				<view class="flex">
					<view class="">
						明细：{{ item.name}}
					</view>
					<view class="">
						{{ item.status == 1 && item.money>=0 ? "+" : item.status == 2?'-':'' }}{{item.money}}
					</view>
				</view>
				
			</view>
			<u-loadmore :status="status" />
		</view>
	</view>
</template>

<script>
	import { changeTime } from '@/utils/time.js'
	export default {
		data() {
			return {
				status: 'loading',
				page: 1,
				pagesize: 10,
				list: [],
				ReachBottom: false,
				user: {}
			}
		},
		onLoad() {
			console.log(changeTime(1704342006))
			this.getdetail()
		},
		onReachBottom() {
		
			let _self = this
			console.log('reach')
		
			uni.showNavigationBarLoading()
			// console.log('reach');
			if(_self.ReachBottom){
				_self.status = 'loading'
				setTimeout(function() {
					_self.page++;
					_self.getdetail();
					uni.hideNavigationBarLoading()
				}, 2000);
			}
			
		
		},
		onPullDownRefresh() {
			//监听下拉刷新动作的执行方法，每次手动下拉刷新都会执行一次
			console.log('refresh');
			setTimeout(function() {
				this.page = 1
				uni.stopPullDownRefresh(); //停止下拉刷新动画
				this.getdetail()
			}, 1000);
		},
		methods: {
			time(t){
				return changeTime(t)
			},
			gotocashlist(){
				uni.navigateTo({
					url: '/pages/jifen/cashlist'
				})
			},
			gotocashRule(){
				uni.navigateTo({
					url: '/pages/jifen/integralRule'
				})
			},
			getdetail(){
				var _this = this
				this.fq_post('wxsite/User/accountIntegral', {
					page: _this.page,
					pagesize: _this.pagesize
				}, (res) => {
					console.log(res)
					if(res.code == 1){
						_this.user = res.data.user
						if (res.data.Integral.length < 10) {
							_this.ReachBottom = false
							// uni.showToast({
							// 	title: '没有更多数据了',
							// 	icon: "none"
							// });
							_this.status = 'nomore'
						}else{
							_this.ReachBottom = true
							_this.status = 'loadmore'
						}
						if (_this.page != 1) {
							_this.list = _this.list.concat(res.data.Integral)
						} else {
							_this.list = res.data.Integral
						}
					}
				})
				// uni.request({
				// 	url: 'http://www.yndzfl.cn/wxsite/User/accountIntegral',
				// 	method: 'POST',
				// 	header:{
				// 		"Content-Type" : "application/x-www-form-urlencoded"
				// 	},
				// 	data: {
				// 		openid: uni.getStorageSync('OPENID'),
				// 		page: _this.page,
				// 		pagesize: _this.pagesize
				// 	},
				// 	success(res) {
				// 		console.log(res)
				// 		if(res.data.code == 1){
				// 			_this.user = res.data.data.user
				// 			if (res.data.data.Integral.length < 10) {
				// 				_this.ReachBottom = false
				// 				uni.showToast({
				// 					title: '没有更多数据了',
				// 					icon: "none"
				// 				});
				// 				_this.status = 'nomore'
				// 			}else{
				// 				_this.ReachBottom = true
				// 				_this.status = 'loadmore'
				// 			}
				// 			if (_this.page != 1) {
				// 				_this.list = _this.list.concat(res.data.data.Integral)
				// 			} else {
				// 				_this.list = res.data.data.Integral
				// 			}
							
				// 		}
						
				// 	}
				// })
			},
			gotodetail(){
				uni.navigateTo({
					url: '/pages/jifen/wxpay'
				})
			},
			cash(){
				uni.navigateTo({
					url: '/pages/jifen/cash'
				})
			}
		}
	}
</script>

<style scoped>
.content{
	min-height: 100vh;
	background-color: #F6f6f6;
}
.bg_header{
	/* margin-top: 10px; */
	width: 100%;
	height: 150px;
	background: url('../../static/icon_02.png') no-repeat;
	background-size: 100% 100%;
	position: relative;
	/* display: flex;
	justify-content: center;
	align-items: center; */
}
.qiu{
	width: 100px;
	height: 100px;
	/* line-height: 100px; */
	background-color: #f19149;
	box-shadow: 0 5rpx 92rpx 8rpx rgba(0,0,0,.13);
	border-radius: 50%;
	color: #fff;
	
	display: flex;
	flex-direction: column;
	justify-content: center;
	align-items: center;
	position: absolute;
	left: 50%;
	top: 45%;
	margin-left: -50px;
	margin-top: -50px;
}
.qiu .text{
	/* height: 30px; */
	text-align: center;
}
.money{
	font-size: 18px;
}
.desc{
	position: absolute;
	bottom: 20px;
	right: 10px;
	width: 100%;
	text-align: right;
	color: #fff;
	font-size: 14px;
}
.tixiantype{
	/* background: #fff; */
	display: flex;
	justify-content: space-between;
	align-items: center;
	position: relative;
}
.cashlist{
	position: absolute;
	top: 8px;
	right: 0px;
	width: 71px;
	height: 25px;
	line-height: 25px;
	text-align: center;
	background-color: #f90;
	color: #fff;
	font-size: 13px;
	border-radius: 10px 0 0 10px;
}
.tixiantype .card{
	width: 49.5%;
	height: 130px;
	
	background-color: #fff;
	text-align: center;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
}
.list_title{
	padding: 10px 5px;
	font-size: 14px;
	font-weight: bold;
}
.list{
	
}
.list_item{
	/* display: flex;
	justify-content: space-around;
	align-items: center; */
	background-color: #fff;
	line-height: 40px;
	margin-top: 5px;
	padding:0 10px;
}
.flex{
	display: flex;
	justify-content: space-between;
	color: #999;
}
</style>
